package com.ygswglxt.auth.controller;

import com.ygswglxt.auth.entity.User;
import com.ygswglxt.auth.service.AuthService;
import com.ygswglxt.common.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/auth")
public class AuthController {
    
    @Autowired
    private AuthService authService;
    
    @PostMapping("/login")
    public Result<Map<String, Object>> login(@RequestBody Map<String, String> params) {
        String username = params.get("username");
        String password = params.get("password");
        return authService.login(username, password);
    }
    
    @PostMapping("/register")
    public Result<String> register(@RequestBody User user) {
        return authService.register(user);
    }
}

